package ui.util;


import javax.swing.*;
import java.awt.*;

public class ListCellRendererWithLP implements ListCellRenderer {

    private final ListCellRenderer originalRenderer;
    private final LabelProvider labelProvider;

    public ListCellRendererWithLP(final ListCellRenderer originalRenderer, final LabelProvider labelProvider) {
        this.originalRenderer = originalRenderer;
        this.labelProvider = labelProvider;
    }

    public Component getListCellRendererComponent(final JList list,
                                                  final Object value, final int index, final boolean isSelected,
                                                  final boolean cellHasFocus) {
        return originalRenderer.getListCellRendererComponent(list,
                labelProvider.toString(value), index, isSelected, cellHasFocus);
    }
}
